home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / comm / 110a115a.zip / SCRIPTS.ZIP / FILEMOD.SLT < prev    next >
Text File  |  1995-12-21  |  4KB  |  106 lines

  1. /****************************************************************/
  2. /*                                                              */
  3. /*  Demo of how to manipulate files from remote, and other      */
  4. /*  file access methods.                                        */
  5. /*                                                              */
  6. /*                   Copyright 1995 deltaComm Development, Inc. */
  7. /*                                                              */
  8. /****************************************************************/
  9.  
  10. main()
  11. {
  12.  
  13. str ph_num[10] = "5551234";
  14. str st[20];
  15. int fil1, fil2;
  16. int result;
  17.  
  18. _up_dir=_down_dir="C:\XILET";
  19.  
  20. loadfon("telix.fbk");
  21. result=1;
  22.  
  23. if (!dial(ph_num, 5, 0))                         // Try to dial number
  24.   {
  25.    prints("No connection, trying some more.");
  26.    result = redial(ph_num, 10, 0);
  27.   }
  28.  
  29. if (result)                                  // Will be true if connected
  30.   {
  31.    waitfor("Name:", 180);                    // Wait for BBS to request name
  32.    cputs("Ditto");                           // Type the name of Jeff's Dog
  33.    cputc("^m");                              // and send a Carriage return
  34.  
  35.    waitfor("password:", 30);
  36.    cputs_tr("ILUVTELIX^M");                  // Password + CR
  37.    prints();
  38.  
  39.    prints("Connecter to:");                  // Display various
  40.    printsc("Dialing Directory: ");           // user and BBS
  41.    prints(_entry_name);                      // information
  42.    printsc("Entry number: ");                // on the screen only.
  43.    prints(_entry_enum);
  44.    printsc("Number: ");
  45.    prints(_entry_num);
  46.    printsc("BBS Type: ");
  47.    prints(_entry_bbstype);
  48.    printsc("Logon Name: ");
  49.    prints(_entry_logonname);
  50.    printsc("Password: ");
  51.    prints(_entry_pass);
  52.    printsc("Comments: ");
  53.    prints(_entry_comment);
  54.  
  55.    // Instruct user to go to the file area
  56.    // and initiate download
  57.  
  58.    prints("Enter file area and download test.txt");
  59.  
  60.    waitfor("begin file transfer", 180);
  61.    dos("MkDir c:\XILET", 0);    // Execute DOS command to create the DIR
  62.    receive('Z', "test.txt");    // Download a file
  63.  
  64.    fil1=fopen("c:\XILET\test.txt", "r");     // Open Fil1 for reading...
  65.    fil2=fopen("c:\XILET\test2.txt", "w");    // Open Fil2 for writing...
  66.  
  67.    fseek(fil1, 0, 10);                       // locate ptr 10 bytes into file
  68.    fgets(st, 5, fil1);                       // Read 5 characters from fil1
  69.    setchr(st, 2, "X");                       // Put an 'X' into the string
  70.    setchrs(st, 6, "x", 5);                   // Add 'x's to the string
  71.    fputs(st, fil2);                          // Write the string to fil2
  72.    fread(st, 10, fil1);                      // Get 10 chars from fil1
  73.    fwrite(st, 10, fil2);                     // Put them in fil2
  74.  
  75.    while (!feof(fil1))                       // Loop testing for eof of fil1
  76.     {
  77.      if (ftell(fil2) and 255)                // transfer characters from Fil1
  78.        fputs("*|*", fil2);                   //    into FIL2
  79.      fputc(fgetc(fil1), fil2);
  80.  
  81.     }
  82.  
  83.    fflush(fil1);                             // Flush file I/O buffers
  84.    fflush(fil2);
  85.  
  86.    fclose(fil1);                             // Close the files
  87.    fclose(fil2);
  88.  
  89.    fdelete("c:\XILET\test.txt");             // Delete original file
  90.  
  91.    frename("c:\XILET\test2.txt", "c:\XILET\test.txt");
  92.    // Rename new file to the old file's name
  93.  
  94.    prints("Now upload test.txt");
  95.    waitfor("begin file transfer", 180);
  96.    send('Z', "test.txt");                    // Upload changed file back to BBS
  97.  
  98.    fdelete("c:\XILET\test.txt");             // Delete the new file
  99.    dos("RemDir c:\XILET", 0);                // Use DOS to kill work directory
  100.  
  101.    printsc("The operation took ");
  102.    printn(getonlinetime());
  103.    prints(" seconds.");
  104.   }
  105. }
  106.